import com.lijinjiang.beautyeye.BeautyEyeLNFHelper;

import javax.swing.*;
import javax.swing.border.MatteBorder;
import java.awt.*;

/**
 * @ClassName Demo01
 * @Description TODO
 * @Author Li
 * @Date 2022/9/15 8:48
 * @ModifyDate 2022/9/15 8:48
 * @Version 1.0
 */
public class Demo01 {
    public static void main(String[] args) {
        try {
            BeautyEyeLNFHelper.frameBorderStyle = BeautyEyeLNFHelper.FrameBorderStyle.generalNoTranslucencyShadow;
            BeautyEyeLNFHelper.launchBeautyEyeLNF();
        } catch (Exception e) {
            e.printStackTrace();
        }
        JFrame frame = new JFrame("Demo01");

        // 创建内容面板，默认使用流式布局
        JPanel panel = new JPanel();
        panel.setLayout(new GridLayout(1, 3, 3, 3));
        MatteBorder matteBorder = BorderFactory.createMatteBorder(2, 5, 2, 2, Color.RED);

        /*
         * 只显示文本
         */
        JLabel label01 = new JLabel();
        label01.setText("武林外传");
        label01.setFont(new Font(null, Font.PLAIN, 25));  // 设置字体，null 表示使用默认字体
        label01.setBorder(BorderFactory.createCompoundBorder(matteBorder, BorderFactory.createTitledBorder("文本标签")));
        panel.add(label01);

        /*
         * 只显示图片
         */
        JLabel label02 = new JLabel();
        label02.setIcon(new ImageIcon("P22_JLabel/images/pic01.png"));
        label02.setBorder(BorderFactory.createCompoundBorder(matteBorder, BorderFactory.createTitledBorder("图片标签")));
        panel.add(label02);

        /*
         * 同时显示文本和图片
         */
        JLabel label03 = new JLabel();
        label03.setText("同福客栈");
        label03.setIcon(new ImageIcon("P22_JLabel/images/pic02.png"));
        label03.setHorizontalTextPosition(SwingConstants.CENTER);   // 水平方向文本在图片中心
        label03.setVerticalTextPosition(SwingConstants.BOTTOM);     // 垂直方向文本在图片下方
        label03.setBorder(BorderFactory.createCompoundBorder(matteBorder, BorderFactory.createTitledBorder("文本和图片标签")));
        panel.add(label03);

        frame.add(panel);
        frame.pack();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }
}
